[WIP] bazel: Add python data providers#17998
Conversation
c4cbb99 to
93d84b9
Compare
|
although this adds some code, it will allow us to reduce code overall, and exposes bazel and bazel data in ways that fits both with bazel's workflow and python's idioms, i think ultimately, it will be very useful shifting any remaining scripts to bazel and tidying up some of the existing bazel rules |
9a35c54 to
391b659
Compare
tools/code_format/check_format.py
Outdated
There was a problem hiding this comment.
cc @envoyproxy/dependency-shepherds
this rule doesnt make sense in the api, which is mounted within an external namespace in envoy' workspace, and can only refer to the envoy targets through the @envoy namespace
perhaps the intention is to prevent accessing the envoy namespace from the api, but then that feels more like a job for visibility
There was a problem hiding this comment.
this could be resolved alternately by shifting these rules into a separate namespace
without this change, the current implementation fails format checking - i guess for good reason
|
the one question im wondering about this is whether it would be better to have the mutators in the the benefit to having the mutators in the write method would be
the downside is added code/complexity - its easier to implement as it is, as there is already a need to add a python template and inject it with data |
|
the other thing is namespacing with current implementation you can import "from" the repo - ie with #17293 the potentially, we could create a directory like rules would have to depend on |
54108d4 to
be897af
Compare
32084ff to
2ae7915
Compare
|
@lizan @htuch before pushing this PR i would like to go through all of the ways in which i want to use it and prepare the following PRs, mostly so i can think through the pattern i would v much like this or something like this to land, and believe i can cut quite a bit of code with it, but i would like to think it through again, so its going to take me a few days |
eb708de to
34a22a3
Compare
tools/data/filters/proto_rst_srcs.py
Outdated
218a3d8 to
219f477
Compare
Signed-off-by: Ryan Northey <ryan@synca.io>
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
There are a few tools that require the repository_locations data, currently we are bringing that data into the python by putting the implementation (as opposed to the abstract library) in the envoy repo, this will allow us to instead pass the repo locations data as a file/cli flag, and move the implementation into the upstream tooling This PR also avoids using the old SourceFileLoader + bzl files method of loading the data, instead loading directly from the write_json rules for the repo files and interpolating There is a more generic implementation of some of what is required here in #17998 Signed-off-by: Ryan Northey <ryan@synca.io>
|
with the move to pytooling this should not be necessary, we can use json data from bazel |
There are a few tools that require the repository_locations data, currently we are bringing that data into the python by putting the implementation (as opposed to the abstract library) in the envoy repo, this will allow us to instead pass the repo locations data as a file/cli flag, and move the implementation into the upstream tooling This PR also avoids using the old SourceFileLoader + bzl files method of loading the data, instead loading directly from the write_json rules for the repo files and interpolating There is a more generic implementation of some of what is required here in envoyproxy#17998 Signed-off-by: Ryan Northey <ryan@synca.io> Signed-off-by: Josh Perry <josh.perry@mx.com>
Signed-off-by: Ryan Northey ryan@synca.io
Commit Message: bazel: Add python data providers
Additional Description:
This is a generalized solution to the problem of getting data from bazel into python tools
It adds a
write_jsonrule that can create a json target from any data serializable by the bazel json parserIt also adds a
py_datarule which allows json or yaml to be imported directly into pythonThe data rule take an optional filters argument which is a chain of mutating rules. The filters deal with python data and are agnostic to the source, but are obv specific to the data being processsed.
This PR adds the required macros and adds rules for ~all of the data currently used in tooling
It doesnt make use of the data - this will be added in a follow up PR
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]